using System;
using RideMe.AddIns.Events;
using RideMe.AddIns.Interfaces;

namespace RideMe.AddIns.Base
{
    /// <summary>
    /// This represents a single application context, used as a singleton, allowing instant access to the various events that the add-ins are subscribed to
    /// </summary>
    public class ApplicationContext : IApplicationContext
    {
        #region Static Constructor

        /// <summary>
        /// Static constructor to support the singleton concept
        /// </summary>
        static ApplicationContext()
        {
        }

        #endregion

        #region Static Properties

        /// <summary>
        /// This returns the current instance of the application context
        /// </summary>
        public static ApplicationContext Current
        {
            get { return _current; }
        }

        #endregion        

        #region Static Variables

        private static ApplicationContext _current = new ApplicationContext();

        #endregion        

        #region Private Variables

        AddInEventSource _addInEvents = new AddInEventSource();
        UserInterfaceEventSource _userInterfaceEvents = new UserInterfaceEventSource();
        ProjectEventSource _projectEvents = new ProjectEventSource();
        EditorEventSource _editorEvents = new EditorEventSource();

        #endregion

        #region IApplicationContext Members

        /// <summary>
        /// This returns the add-in event source, used by an add-in to subscribe to add-in related events
        /// </summary>
        public AddInEventSource AddInEvents
        {
            get { return _addInEvents; }
        }

        /// <summary>
        /// This returns the user interface event source, for subscribing to ui related events
        /// </summary>
        public UserInterfaceEventSource UserInterfaceEvents
        {
            get { return _userInterfaceEvents; }
        }

        /// <summary>
        /// This returns the project event source, used for being informed about project events
        /// </summary>
        public ProjectEventSource ProjectEvents
        {
            get { return _projectEvents; }
        }

        /// <summary>
        /// This returns the editor event source, used to keep add-ins informed about editor updates and events
        /// </summary>
        public EditorEventSource EditorEvents
        {
            get { return _editorEvents; }
        }

        #endregion
    }
}
